require(['jquery', 'cookie', 'app', 'lay'], function ($) {
    require(['vue'], function (Vue) {
        var dic = new Vue({
            el: ".vue-box"
            , data: {
                where: [],
                th:{}
            }
            , created: function () {
                this.loadPage()
            }
            , methods: {
                loadPage: function () {
                    var json = {};
                    json["APPID"] = "550e8400-e29b-41d4-a716-446655440000";
                    json["uuid"] = "1566381003874";
                    var re = playAjax("1574998957822", json);
                    var toolbar = [];
                    toolbar[0] = {
                        "clas": "",
                        "eve": "BAND",
                        "tit": "禁用/启用",
                        "fnc": function (data) {
                            if (data.length == 0) {
                                alr("请选中一行！");
                                return false;
                            } else {
                                debugger;
                                loadT();
                                var re = playAjax("1574998957824", data[0]);
                                closeLoad();
                                alr(re.title);
                            }
                        }
                    };
                    toolbar[1] = {
                        "clas": "",
                        "eve": "UPDATE",
                        "tit": "修改",
                        "fnc": function (data) {
                            if (data.length == 0) {
                                alr("请选中一行！");
                                return false;
                            } else {
                                dic.th=data[0];
                                $("html,body").animate({scrollTop: $(".layui-tab-content").offset().top}, 500);
                                layui.use(['element'], function () {
                                    var element = layui.element;
                                    element.tabChange('docDemoTabBrief', '2');
                                });

                                setTimeout(function () {
                                    layui.use(['element'], function () {
                                        var form = layui.form;
                                        form.render();
                                    })
                                },1500);
                            }
                        }
                    };
                    if (re.code == '0') {
                        bspVIEW($(".sa-table"), "1566381003873", JSON.parse(re.data), this.where, toolbar);
                    }
                },
                seachs: function () {
                    this.where = whereJSON($(".el-form"));
                    this.loadPage();
                },
                referXadmin: function () {
                    window.location.reload();
                },
                xz_state: function (e) {
                    var e = e.currentTarget;
                    layer.open({
                        type: 2
                        , content: "./vsp?code=1574998957825&token=" + new acquire().parameterMap['token']
                        , area: ["800px", "400px"]
                        , btn: ['确定', '取消']
                        , yes: function (index, layero) {
                            debugger;
                            var body = layer.getChildFrame('body', index);
                            var w = $(layero).find("iframe")[0].contentWindow;
                            var jon = w.checkSure();
                            $(e).val(jon['F_ROLE_NAME']);
                            $(e).attr("uuid", jon['F_ROLE_CODE']);
                            layer.closeAll();
                        }
                        , btn2: function (index, layero) {
                            layer.closeAll();
                        }
                        , cancel: function () {
                            layer.closeAll();
                        }
                    });
                }
            }
        });
        layui.use('form', function () {
            var form = layui.form;
            form.render();
            form.on('submit(formDemo)', function (data) {
                var jon = data.field;
                if (jon['F_PASSWORD'] != jon['passWord2']) {
                    alr("两次输入密码不一致，请重新输入！");
                    return false;
                }
                if (jon['F_IPONE'] != '' && jon['F_IPONE'] != null) {
                    if (!checkPhone(jon['F_IPONE'])) {
                        alr("请输入正确的手机号！");
                        return false;
                    }
                }
                if (jon['F_EMIL'] != '' && jon['F_EMIL'] != null) {
                    if (!checkEmail(jon['F_EMIL'])) {
                        alr("请输入正确的邮箱！");
                        return false;
                    }
                }
                if (!jon['F_STATUS']) {
                    jon['F_STATUS'] = '1';
                } else {
                    jon['F_STATUS'] = '0'
                }
                var x = $('input[name="F_STATE_NAME"]');
                jon['F_STATE'] = $(x[1]).attr("uuid");
                var re = playAjax("1574998957823", jon);
                alr(re['title']);
                if (re['code'] == '0') {
                    setTimeout(function () {
                        dic.referXadmin();
                    }, 500);
                }
                return false;
            });
            form.on('submit(formDemos)', function (data) {
                debugger;
                var jon = data.field;
                if (jon['F_PASSWORD'] != jon['passWord2']) {
                    alr("两次输入密码不一致，请重新输入！");
                    return false;
                }
                if (jon['F_IPONE'] != '' && jon['F_IPONE'] != null) {
                    if (!checkPhone(jon['F_IPONE'])) {
                        alr("请输入正确的手机号！");
                        return false;
                    }
                }
                if (jon['F_EMIL'] != '' && jon['F_EMIL'] != null) {
                    if (!checkEmail(jon['F_EMIL'])) {
                        alr("请输入正确的邮箱！");
                        return false;
                    }
                }
                if (!jon['F_STATUS']) {
                    jon['F_STATUS'] = '1';
                } else {
                    jon['F_STATUS'] = '0'
                }
                var x = $('input[name="F_STATE_NAME1"]');
                jon['F_STATE'] = $(x).attr("uuid");
                jon['uuid']=dic.th.UUID;
                var re = playAjax("1574998957823", jon);
                alr(re['title']);
                if (re['code'] == '0') {
                    setTimeout(function () {
                        dic.referXadmin();
                    }, 500);
                }
                return false;
            });
        })
    })

});
